﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Inicio.Entities;
using System.Data.SqlServerCe;

namespace Inicio.Core.Repositories
{
    public class CurrencyRepositorie
    {
        public List<Currency> LoadCurrency(string conec)
        {
            List<Currency> currencys = new List<Currency>();

            using (SqlCeConnection cn = new SqlCeConnection(conec))
            {
                cn.Open();
                using (SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Currency ORDER BY description ASC", cn))
                {
                    using (SqlCeDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            currencys.Add(new Currency((int)reader["id"], reader["description"].ToString()));
                        }
                    }
                }
            }
            return currencys;
        }

    }
}
